#include "widget.h"
#include "ui_widget.h"
#include<QDebug>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    connect(ui->pushButton,&QPushButton::clicked,this,&Widget::handleClick);
    QPushButton *mybutton=new QPushButton(this);
    mybutton->setText("按钮");
    mybutton->move(200,300);
    connect(this,&Widget::signal1,this,&Widget::handclose);
    connect(mybutton,&QPushButton::clicked,this,[mybutton](){
        qDebug()<<"lambda被执行了\n";
        mybutton->move(300,300);
    });

}

Widget::~Widget()
{
    delete ui;
}

void Widget::handclose(const QString &text)
{
    qDebug()<<text<<"\n";
}
void Widget::handleClick()
{
    if(ui->pushButton->text()==QString("Hello World"))
    {
        ui->pushButton->setText("Hello Qt");
    }
    else
    {
        ui->pushButton->setText("Hello World");
    }
     qDebug()<<"hello 2\n";
     emit signal1("what can i say");
}

void Widget::on_pushButton_2_clicked()
{
    emit signal1("manba out");
}
